//
//  BorrowTableViewCell.m
//  TenThousand
//
//  Created by 我的 on 16/6/24.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "BorrowTableViewCell.h"

@implementation BorrowTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

//cell赋值
- (void)setDataWithModel:(BorrowModel *)model{
    
    _Code.text = [NSString stringWithFormat:@"%@%@",model.PrjectName,model.Code];
    _Ratejiekuan.text = [NSString stringWithFormat:@"%@",model.Rate];
    _TeamYear.text = [NSString stringWithFormat:@"%@",model.Tearm];
    _MaxPrice.text = [NSString stringWithFormat:@"借款本金:%@",model.Amount];
    _Totaljiekuanlixi.text = [NSString stringWithFormat:@"借款利息:%@",model.interest];
    _AddTime.text = [NSString stringWithFormat:@"%@",model.AddDate];//时间分割
    _PaySate.text = [NSString stringWithFormat:@"状态:%@",model.Sate];
    
   
    
}

- (void)setDataAndModel:(BorrowModel *)model{
    
    _Code.text = [NSString stringWithFormat:@"%@%@",model.PrjectName,model.Code];
    _Ratejiekuan.text = [NSString stringWithFormat:@"%@",model.Ratejiekuan];
    _TeamYear.text = [NSString stringWithFormat:@"%@",model.TeamYear];
    _MaxPrice.text = [NSString stringWithFormat:@"借款本金:%@",model.MaxPrice];
    _Totaljiekuanlixi.text = [NSString stringWithFormat:@"借款利息:%@",model.Totaljiekuanlixi];
    _AddTime.text = [NSString stringWithFormat:@"%@",model.AddTime];//时间分割
    _PaySate.text = [NSString stringWithFormat:@"状态:%@",model.PaySate];

    
}

/**
 *  时间对比
 *
 *  @param startDate 开始时间
 *  @param endDate 结束时间
 *
 *  @return 比较返回值
 */
- (NSString *)dateCompare:(NSString *)startDate and:(NSString *)endDate {
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
    formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
    NSDate *startDay = [formatter dateFromString:startDate];
    NSDate *endDay = [formatter dateFromString:endDate];
    NSTimeInterval seconds = [endDay timeIntervalSinceDate:startDay];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    
    [numberFormatter setPositiveFormat:@"0"];
    
    return [numberFormatter stringFromNumber:[NSNumber numberWithFloat:seconds / (60 * 60 * 24)]];
}


@end
